
var Calendar = new Class({
    Implements: [Events, Options],

    options: {
        'tagid': null
    },
    initialize: function(options) {
        if(!options.tagid) return;
        this.setOptions(options);

        this.begDate = new Element('input[type=text][maxlength=10]');
        this.endDate = new Element('input[type=text][maxlength=10]');
        new Element('div#selDate').adopt(
            this.begDate,
            new Element('tt[text= - ]'),
            this.endDate,
            new Element('input[type=submit][value=Get]', {
                    'events': {
                        'click': this.getDate.bind(this)
                    }
            })
        ).inject(this.options.tagid);

	new DatePicker([this.begDate, this.endDate], {
            format: '%Y-%m-%d',
            inputOutputFormat: 'Y-m-d'
        });

    },
    getDate: function() {
        this.fireEvent('select', [this.begDate.value, this.endDate.value])
    }
});
